package vip.george.realm.chain;

import org.apache.shiro.authc.*;
import org.apache.shiro.realm.AuthenticatingRealm;
import vip.george.entity.User;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @author gehaodong
 * @since 2024/3/11
 * <p>
 *     多Realm认证，第一个Realm
 * </P>
 */
public class MyRealmChainOne extends AuthenticatingRealm {

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {

        UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) token;

        // 这里不从数据库中查询用户，直接将前端用户输入的结果返回，这样这个Realm永远是成功的
        return new SimpleAuthenticationInfo("always_user", token.getCredentials(), getName());
    }
}
